<template>
  <div v-if="visible" class="dialog-mask" @click.self="close">
    <div class="dialog-content">
		
      <slot></slot>
      <button class="dialog-close" @click="close">×</button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, defineExpose } from 'vue'

const props = defineProps({
	isClose: {
		type: Boolean,
		default: false
	}
})
const visible = ref(false)
const emit = defineEmits(['close'])
function open() {
  visible.value = true
}
function close2() {
  visible.value = false

}
function close() {
  if (!props.isClose) {
    visible.value = false
  } else { 
    emit('close')
  }
}

defineExpose({ open, close,close2 })
</script>

<style scoped>
.dialog-mask {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.dialog-content {
  position: relative;
  min-width: 320px;
  min-height: 140px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(30,94,146,0.18), 0 2px 8px rgba(0,0,0,0.12);
  padding: 20px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dialog-close {
  position: absolute;
  top: 3px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: #888;
  cursor: pointer;
  transition: color 0.2s;
}
.dialog-close:hover {
  color: #1e5e92;
}
</style>
